package com.io.service.impl;

import com.io.dao.ProductDaoI;
import com.io.dto.ProductReq;
import com.io.dto.ProductRes;
import com.io.entity.Product;
import com.io.service.ProductServiceI;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * The class/interface
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
@Service
public class ProductServiceImpl implements ProductServiceI {
    @Autowired
    private ProductDaoI productDaoI;

    @Override
    public ProductRes findById(ProductReq productReqDTO) {
        Product product = productDaoI.findById(productReqDTO.getPid()).orElse(new Product());
        ProductRes productResDTO = new ProductRes();
        BeanUtils.copyProperties(product, productResDTO);
        return productResDTO;
    }
}
